package com.example.mobile2021606134chhnewdemo.ContactModule;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.Window;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.example.mobile2021606134chhnewdemo.MapModule.MapActivity;
import com.example.mobile2021606134chhnewdemo.NewsModule.NewsActivity;
import com.example.mobile2021606134chhnewdemo.R;
import com.example.mobile2021606134chhnewdemo.VideoModule.VideoActivity;
import com.example.mobile2021606134chhnewdemo.WeatherModule.WeatherActivity;

import java.util.ArrayList;
import java.util.List;

import me.sugarkawhi.bottomnavigationbar.BottomNavigationBar;
import me.sugarkawhi.bottomnavigationbar.BottomNavigationEntity;

public class ContactActivity extends AppCompatActivity {
    List<BottomNavigationEntity> entities = new ArrayList<>();
    private BottomNavigationBar bottomNavigationBar;
    private RecyclerView rvContact;
    private List<ContactMain> list = new ArrayList<>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
        setContentView(R.layout.activity_contact);
        getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.title_bar);
        initBottomBar();
        initView();
        list.add(new ContactMain("图灵Robot", R.drawable.tulinrobot));
        list.add(new ContactMain("智能问答", R.drawable.speedrobot));

        rvContact.setLayoutManager(new LinearLayoutManager(getApplicationContext()));
        rvContact.setAdapter(new ContactRViewAdapter(list, getApplicationContext()));
    }

    private void initBottomBar() {
        entities.add(new BottomNavigationEntity("通讯", R.drawable.communication_d, R.drawable.communication_s));
        entities.add(new BottomNavigationEntity("视频", R.drawable.play_d, R.drawable.play_s));
        entities.add(new BottomNavigationEntity("   ", R.drawable.new_d, R.drawable.new_s));
        entities.add(new BottomNavigationEntity("导航", R.drawable.navigation_d, R.drawable.navigation_s));
        entities.add(new BottomNavigationEntity("天气", R.drawable.weather_d, R.drawable.weather_s));
        bottomNavigationBar = findViewById(R.id.BNBContact);
        bottomNavigationBar.setEntities(entities);
        bottomNavigationBar.setCurrentPosition(0);
        bottomNavigationBar.setBnbItemDoubleClickListener(new BottomNavigationBar.IBnbItemDoubleClickListener() {
            @Override
            public void onBnbItemDoubleClick(int position) {
                Log.i("bottomNavigationBar", "重复选中" + position);
            }
        });
        bottomNavigationBar.setBnbItemSelectListener(new BottomNavigationBar.IBnbItemSelectListener() {
            @Override
            public void onBnbItemSelect(int position) {
                Log.i("bottomNavigationBar", "选中" + position);
                switch (position) {
                    case 0:
                        break;
                    case 1:
                        Intent intent4 = new Intent(getApplicationContext(), VideoActivity.class);
                        startActivity(intent4);
                        finish();
                        overridePendingTransition(0, 0);
                        break;
                    case 2:
                        Intent intent = new Intent(getApplicationContext(), NewsActivity.class);
                        startActivity(intent);
                        finish();
                        overridePendingTransition(0, 0);
                        break;
                    case 3:
                        Intent intent3 = new Intent(getApplicationContext(), MapActivity.class);
                        startActivity(intent3);
                        finish();
                        overridePendingTransition(0, 0);
                        break;
                    case 4:
                        Intent intent1 = new Intent(getApplicationContext(), WeatherActivity.class);
                        startActivity(intent1);
                        finish();
                        overridePendingTransition(0, 0);
                        break;
                }
            }
        });
    }

    private void initView() {
        rvContact = (RecyclerView) findViewById(R.id.rvContact);
    }
}